package gdut.stream.last;

import java.util.ArrayList;
import java.util.Optional;

public class FindFirstTest {
    public static void main(String[] args) {
        ArrayList<Integer> integers = new ArrayList<>();
        for (int i = 0; i < 100; i++) {
            integers.add(i);
        }
//        findFirst获取流中的第一个元素
        Optional<Integer> first = integers.stream()
                .findFirst();
        first.ifPresent(integer -> System.out.println(integer));
    }
}
